
<template>
  <div class="tablePage">
    <h1>任务列表</h1>
    <div style="margin-bottom: 20px">
      <span>任务名称：</span>
      <input
        type="text"
        v-model="biaoti"
        placeholder="输入提示"
        status="info"
        style="width:280px;display:inline-block"
      />
      <input type="button" value="查询" @click="selectData" />
    </div>
    <div>
      <!-- 表格-->
      <v-table
        :columns="tableConfig.columns"
        :table-data="tableConfig.tableData"
        :paging-index="(pageIndex-1)*tiaoshu"
      ></v-table>
      <!-- 分页-->
      <v-pagination
        @page-change="pageChange"
        @page-size-change="pageSizeChange"
        :total="total"
        :page-size="tiaoshu"
        :layout="['total', 'prev', 'pager', 'next', 'sizer', 'jumper']"
      ></v-pagination>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      pageIndex: 1,
      tiaoshu: 10,
      total: 0,
      biaoti: "",
      tableConfig: {
        tableData: [],
        columns: [
          {
            field: "Id",
            title: "编号",
            width: 50,
            columnAlign: "center"
          },
          {
            field: "fawendanweimingcheng",
            title: "发文单位",
            width: 250,
            columnAlign: "center"
          },
          {
            field: "wenhao",
            title: "文号",
            width: 150,
            columnAlign: "center"
          },
          {
            field: "biaoti",
            title: "标题",
            width: 300,
            columnAlign: "center"
          },

          {
            field: "fawenshijian",
            title: "发文时间",
            width: 300,
            columnAlign: "left"
          }

          //   {
          //     field: "score",
          //     title: "成绩",
          //     width: 80,
          //     columnAlign: "center"
          //   }
        ]
      }
    };
  },
  created() {
    this.getTableData();
  },
  methods: {
      /**查询数据 */
    getTableData() {
        //let limit=this.tiaoshu*this.pageIndex;
      this.$axios
        .post(
          "http://2924c72s24.wicp.vip:14018/httpapi/DcShengjirenwuapi/getlist",
          {
            pageNumber: this.pageIndex,
            pageSize: this.tiaoshu,
            biaoti: this.biaoti
          }
        )
        .then(res => {
          console.log("res", res);
          if (res.data.code == "200") {
            this.tableConfig.tableData = res.data.rows;
            this.total = res.data.total;
          }
        })
        .catch(error => {
          console.log(error);
        });
    },
    /**翻页事件 */
    pageChange(pageIndex) {
      this.pageIndex = pageIndex;
      this.getTableData();
      console.log(pageIndex);
    },
    /**每页行数改变事件 */
    pageSizeChange(tiaoshu) {
      this.pageIndex = 1;
      this.tiaoshu = tiaoshu;
      this.getTableData();
    },
    /**查询数据 */
    selectData() {
      this.getTableData();
    }
  }
};
</script>
